﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using DevExpress.Xpo;
using Aij1.Model;
using Aij1.BLL;
using System.Collections;
using QConnectSDK;

namespace Aij1.Cms
{
    public class BasePage : Page
    {
        public Session XpoSession;
        public S_Person CurrentUser;
        public C_Customer CurrentCustomer;
        public string CompanyName;
        public string PageName;
        public string Keywords;
        public string Description;
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            CompanyName = Config.CompanyName;
            if (!DesignMode)
            {
                if (XpoSession == null) XpoSession = XpoHelper.GetNewSession();
                if (CurrentUser == null) CurrentUser = AuthData.GetCurrentUser(XpoSession);
                if (CurrentCustomer == null) CurrentCustomer = AuthData.GetCurrentCustomer(XpoSession);

#if DEBUG
                if (CurrentCustomer == null)
                {
                    CurrentCustomer = XpoSession.GetObjectByKey<C_Customer>(2);
                    AuthData.SetCurrentCustomer(CurrentCustomer);
                }
#endif
            }
        }

    }
}